import http from '@/utils/request'

class CustomUploadAdapter {
  constructor (loader) {
    this.loader = loader
  }

  upload () {
    return this.loader.file.then(file => {
      return new Promise((resolve, reject) => {
        console.log(file)
        http.post('/file/upload').then(({ data }) => {
          resolve(data.url)
        }).catch(() => {
          reject(new Error('上传失败'))
        })
      })
    })
  }

  abort () {
    // 待实现
  }
}

export default CustomUploadAdapter
